package com.crusinnovation.unitTest.formatter;

import static org.junit.Assert.assertEquals;

import java.util.GregorianCalendar;

import org.junit.Before;
import org.junit.Test;

import com.cyrusinnovation.test.formatter.PersonRecordFormatter;
import com.cyrusinnovation.test.formatter.SpaceRecordFormatter;
import com.cyrusinnovation.test.record.Gender;
import com.cyrusinnovation.test.record.PersonRecord;

public class SpaceRecordFormatterTest {
	String recordString1="LastName FirstName MiddleInitial M 11-1-1997 FavoriteColor";
	String recordString2="";
	PersonRecord record1=new PersonRecord();
	PersonRecord record2=new PersonRecord();
	PersonRecordFormatter formatter = new SpaceRecordFormatter();

	@Before
	public void setUp() throws Exception {
		record1.setLastName("LastName");
		record1.setFirstName("FirstName");
		record1.setGender(Gender.MALE);
		record1.setFavoriteColor("FavoriteColor");
		GregorianCalendar calendar = new GregorianCalendar();
		calendar.set(1997,10,1);
		record1.setDateOfBirth(calendar.getTime());
	}
	
	@Test
	public void testPersonRecordToString() {
		String str = "LastName FirstName  Male 11-1-1997 FavoriteColor";
		assertEquals(formatter.PersonRecordToString(record1),0,str.compareToIgnoreCase(formatter.PersonRecordToString(record1)));
		str = "     ";
		assertEquals(formatter.PersonRecordToString(record2),0,str.compareToIgnoreCase(formatter.PersonRecordToString(record2)));
	}
	
	@Test
	public void testStringToPersonRecord() {
		PersonRecord record = formatter.StringToPersonRecord(recordString1);
		assertEquals(formatter.PersonRecordToString(record),record,record1);
		record = formatter.StringToPersonRecord(recordString2);
		assertEquals(formatter.PersonRecordToString(record),record,record2);
	}

}
